package app.fugema.shop.main.invoice.adapter;

import android.view.View;

import androidx.annotation.NonNull;

import com.base.common.utils.DensityUtil;
import com.base.common.utils.ViewUtils;
import com.base.common.view.adapter.ada.SingleUniversalAdapter;
import com.base.common.view.adapter.connector.BaseViewHolder;
import app.fugema.shop.R;
import app.fugema.shop.main.center.model.CollectGoodsResult;

import java.util.List;


public class CollectProductAdapter extends SingleUniversalAdapter<CollectGoodsResult.CollectGoods>
{

    private boolean isEdit = false;

    public void setEdit(boolean edit)
    {
        this.isEdit = edit;
        notifyDataSetChanged();
    }

    @Override
    public int getLayoutId()
    {
        return R.layout.item_collect_goods_view;
    }

    @Override
    public void onBindViewHolder(@NonNull BaseViewHolder holder, int position)
    {
        super.onBindViewHolder(holder, position);

        if (position == getLastPosition()) {
            ViewUtils.setViewMarginTop(holder.itemView, 0, DensityUtil.getDimens(R.dimen.dp_30));
        } else {
            ViewUtils.setViewMarginTop(holder.itemView, 0, 0);
        }

        if (isEdit)
        {
            holder.itemView.findViewById(R.id.btn_delete).setVisibility(View.VISIBLE);
        }
        else
        {
            holder.itemView.findViewById(R.id.btn_delete).setVisibility(View.INVISIBLE);
        }
    }

    @Override
    public void onBindViewHolder(@NonNull BaseViewHolder holder, int position, @NonNull List<Object> payloads)
    {
        super.onBindViewHolder(holder, position, payloads);

    }
}
